Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix broken build cache caused by rustdoc builds #126934

Merged
merged 1 commit into from
Jun 26, 2024

Conversation

onur-ozkan
Copy link
Member

@onur-ozkan onur-ozkan commented Jun 25, 2024

Currently rustdoc breaks the build cache (due to having different rustflags) when building rustdoc before building another tool (e.g., x test miri && x test rustdoc && x test miri).

This change fixes that by moving on-broken-pipe into prepare_cargo_tool so it is set for all tools.

cc @RalfJung

Fixes #123177

@rustbot
Copy link
Collaborator

rustbot commented Jun 25, 2024

r? @clubby789

rustbot has assigned @clubby789.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jun 25, 2024
@onur-ozkan
Copy link
Member Author

@clubby789 is not active these days and this is a contributor roadblock.

So, r? @Kobzol

@RalfJung
Copy link
Member

The flag is also set here, is that expected duplication?

// If the rustc output is piped to e.g. `head -n1` we want the process to be
// killed, rather than having an error bubble up and cause a panic.
cargo.rustflag("-Zon-broken-pipe=kill");

// If the rustdoc output is piped to e.g. `head -n1` we want the process
// to be killed, rather than having an error bubble up and cause a
// panic.
cargo.rustflag("-Zon-broken-pipe=kill");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this was added in cde0cde, regressing the fix I made in #123192. Seems likely this will regress again.

Can you add a comment here saying to not add any rustflags, as that will cause undesired rebuilds?

Copy link
Member Author

@onur-ozkan onur-ozkan Jun 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment here saying to not add any rustflags, as that will cause undesired rebuilds?

We need to duplicate that comment for every impl Step for $tool to make it clear, which wouldn't be not good enough either (because people can miss comments sometimes). As I mentioned in #123177 (comment), I will create a follow-up PR later this week to have this automatically checked. So the test can ensure tools never break the build cache again.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤷 IMO one can't have too many comments (or at least, that is very hard). Tests are nice but they only catch things after someone already made their PR, when CI runs. And tests can't cover all combinations of tools either.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely need a change that ensures we never end up breaking the cache again (for any tool not just rustdoc).

Added a comment for rustdoc as it's harmless to have.

@onur-ozkan
Copy link
Member Author

The flag is also set here, is that expected duplication?

// If the rustc output is piped to e.g. `head -n1` we want the process to be
// killed, rather than having an error bubble up and cause a panic.
cargo.rustflag("-Zon-broken-pipe=kill");

This PR changes rustflags for tools and the one you linked is for rustc builds. So, it is expected.

@Kobzol
Copy link
Contributor

Kobzol commented Jun 25, 2024

I wonder if we could return some "sealed" variant of CargoCommand from prepare_tool_cargo, so that it is not possible to modify its rustflags after creation anymore, to prevent issues like this. But it's probably only a problem for tools that are actually a part of a sysroot, like rustdoc, lld-wrapper etc. Maybe we could somehow mark these (in the type system) to make sure that it is not possible to break the cache.

But in any case, that's a more of a long-term goal, this PR looks reasonable as a hotfix.

@onur-ozkan onur-ozkan force-pushed the broken-build-cache branch 2 times, most recently from 191f594 to 2e017f4 Compare June 25, 2024 09:43
@Kobzol
Copy link
Contributor

Kobzol commented Jun 25, 2024

The comment is a (slight) improvement over the status quo. Feel free to r=me.

@onur-ozkan
Copy link
Member Author

@bors r=Kobzol rollup

@bors
Copy link
Contributor

bors commented Jun 25, 2024

📌 Commit 2e017f4 has been approved by Kobzol

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 25, 2024
compiler-errors added a commit to compiler-errors/rust that referenced this pull request Jun 25, 2024
…obzol

fix broken build cache caused by rustdoc builds

Currently rustdoc breaks the build cache (due to having different rustflags) when building rustdoc before building another tool (e.g., `x test miri && x test rustdoc && x test miri`).

This change fixes that by moving `on-broken-pipe` into `prepare_cargo_tool` so it is set for all tools.

cc `@RalfJung`

Fixes rust-lang#123177
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 25, 2024
…mpiler-errors

Rollup of 7 pull requests

Successful merges:

 - rust-lang#126893 (Eliminate the distinction between PREC_POSTFIX and PREC_PAREN precedence level)
 - rust-lang#126907 (Fixes for 32-bit SPARC on Linux)
 - rust-lang#126932 (Tweak `FlatPat::new` to avoid a temporarily-invalid state)
 - rust-lang#126934 (fix broken build cache caused by rustdoc builds)
 - rust-lang#126943 (De-duplicate all consecutive native libs regardless of their options)
 - rust-lang#126946 (Add missing slash in `const_eval_select` doc comment)
 - rust-lang#126947 (Delegation: ast lowering refactor)

r? `@ghost`
`@rustbot` modify labels: rollup
@matthiaskrgr
Copy link
Member

failed in #126950
@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 25, 2024
@onur-ozkan onur-ozkan force-pushed the broken-build-cache branch 2 times, most recently from 31e997a to 808ac1a Compare June 26, 2024 04:56
@rust-log-analyzer

This comment has been minimized.

Currently rustdoc breaks the build cache (due to having different rustflags) when building
rustdoc before building another tool (e.g., `x test miri && x test rustdoc && x test miri`).

This change fixes that by moving `on-broken-pipe` into `prepare_cargo_tool` so it is
set for all tools.

Signed-off-by: onur-ozkan <work@onurozkan.dev>
@onur-ozkan
Copy link
Member Author

@bors r+ rollup=iffy p=1

@bors
Copy link
Contributor

bors commented Jun 26, 2024

📌 Commit b3fb67e has been approved by onur-ozkan

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 26, 2024
@onur-ozkan
Copy link
Member Author

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 26, 2024
@onur-ozkan
Copy link
Member Author

@bors r=Kobzol

@bors
Copy link
Contributor

bors commented Jun 26, 2024

📌 Commit b3fb67e has been approved by Kobzol

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 26, 2024
@bors
Copy link
Contributor

bors commented Jun 26, 2024

⌛ Testing commit b3fb67e with merge bae813a...

@bors
Copy link
Contributor

bors commented Jun 26, 2024

☀️ Test successful - checks-actions
Approved by: Kobzol
Pushing bae813a to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 26, 2024
@bors bors merged commit bae813a into rust-lang:master Jun 26, 2024
7 checks passed
@rustbot rustbot added this to the 1.81.0 milestone Jun 26, 2024
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (bae813a): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (primary 3.1%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
3.1% [3.1%, 3.1%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 3.1% [3.1%, 3.1%] 1

Cycles

Results (primary 1.6%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.6% [1.6%, 1.6%] 1
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) 1.6% [1.6%, 1.6%] 1

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 694.92s -> 695.46s (0.08%)
Artifact size: 326.70 MiB -> 326.69 MiB (-0.00%)

@onur-ozkan onur-ozkan deleted the broken-build-cache branch June 26, 2024 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Running ./x.py test miri --stage 0 twice rebuilds miri, cargo-miri, and rustdoc
9 participants